# -*- conding:UTF-8 -*-

'''
@ Project: P8 hw register_login
@ File: token_generate.py
@ Author: 罗婷
@ Date：2022/6/17 11:11

'''
import datetime

import jwt
from flask import current_app


# 生成token
def generate_token(payload):
    expire = datetime.datetime.now() + datetime.timedelta(hours=2)
    secret = current_app.config.get('SECRITE_KEY')
    payload.update({'exp': expire})
    token = jwt.encode(payload, secret, algorithm='HS256')
    return token






